//
//  MinePostItemView.m
//  JiaoX
//
//  Created by yinqy on 15/3/20.
//  Copyright (c) 2015年 北京娇羞科技有限公司. All rights reserved.
//

#import "MinePostItemView.h"

@interface MinePostItemView()
{
    UILabel *_titleLabel;
    UIButton *_timeLabel;
    UILabel *_reasonLabel;
    UILabel *_statusLabel;
    UIImageView *_arrowImage;
}

@end

@implementation MinePostItemView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _titleLabel = [[UILabel alloc]init];
        [_titleLabel setFont:NAME_FONT];
        [_titleLabel setTextColor:JXColor(51, 51, 51)];
        [self addSubview:_titleLabel];
        
        _arrowImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"self_item_arrow"]];
        [self addSubview:_arrowImage];
        
        _timeLabel = [[UIButton alloc]init];
        [_timeLabel.titleLabel setFont:TIME_FONT];
        [_timeLabel setTitleColor:JXColor(153, 153, 153) forState:UIControlStateNormal];
        [_timeLabel setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
        [_timeLabel setImage:[UIImage imageNamed:@"ic_time_tint"] forState:UIControlStateNormal];
        [_timeLabel setTitleEdgeInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
        [self addSubview:_timeLabel];
        
        _reasonLabel = [[UILabel alloc]init];
        [_reasonLabel setFont:TIME_FONT];
        [_reasonLabel setTextColor:JXThemeColor];
        [self addSubview:_reasonLabel];
        
        _statusLabel = [[UILabel alloc]init];
        [_statusLabel setFont:TIME_FONT];
        [_statusLabel setTextAlignment:NSTextAlignmentRight];
        [self addSubview:_statusLabel];
    }
    return self;
}

-(void)setMinePostItemframe:(MinePostItemFrame *)minePostItemframe{
    _minePostItemframe = minePostItemframe;
    
    self.frame = minePostItemframe.frame;
    
    MineInteract *interact = minePostItemframe.interact;
    
    [_titleLabel setFrame:minePostItemframe.nameFrame];
    [_titleLabel setText:interact.postsTitle];
    
    [_timeLabel setFrame:minePostItemframe.timeBtnFrame];
    [_timeLabel setTitle:interact.createTime forState:UIControlStateNormal];
    
    [_reasonLabel setFrame:minePostItemframe.reasonFrame];
    [_statusLabel setFrame:minePostItemframe.statusFrame];
    [_arrowImage setFrame:minePostItemframe.arrowFrame];
    [_arrowImage setCenterY:_statusLabel.centerY];
    if (interact.status == 0) {
        //待审核
        [_statusLabel setText:@"待审核"];
        [_statusLabel setTextColor:JXThemeColor];
        [_arrowImage setHidden:YES];
        
    }else if(interact.status == 1){
        //审核通过
        [_statusLabel setText:@"审核通过"];
        [_statusLabel setTextColor:JXColor(153, 153, 153)];
        [_arrowImage setHidden:NO];
        
    }else{
        //审核不通过
        [_statusLabel setText:@"审核未通过"];
        [_statusLabel setTextColor:JXThemeColor];
        [_reasonLabel setText:interact.season];
        [_arrowImage setHidden:YES];
    }
}

@end
